home *** CD-ROM | disk | FTP | other *** search
/ PC Open 107 / PC Open 107 CD 2.bin / CD2 / PDF / Corsi / PHP / lezione_5 / commenti / index.php
Encoding:
PHP Script  |  2004-12-30  |  3.8 KB  |  71 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4.     <title>COMMENTI - home page</title>
  5.     <link rel=stylesheet href="servizi/commenti.css" type="text/css">
  6. </head>
  7. <body>
  8. <?php
  9.     include "servizi/conn.php";
  10. ?>
  11. <div class="titolo">Commenti on line</div><p>
  12. <?php
  13.     // estraggo le descrizioni della home page e le salvo nell'array $home per usare poi la descrizione dove serve
  14.     $sql="SELECT id_testo, testo FROM testi_admin WHERE id_testo LIKE 'home_%'";
  15.     $ris=mysql_query($sql);
  16.     while ($tab=mysql_fetch_array($ris)) {
  17.         $home[$tab[id_testo]]=$tab[testo];
  18.     }    
  19.     // visualizzo il testo che nella tabella testi_admin corrisponde all'identificativo 'home_p'
  20.     echo $home['home_p'];
  21. ?>
  22. <div class="paragrafo">I commenti</div>
  23. <span class="normale">
  24. <?php
  25.     // visualizzo il testo che nella tabella testi_admin corrisponde all'identificativo 'home_i'
  26.     echo $home['home_i'];
  27. ?>
  28. </span>
  29. <div class="tem">
  30.     <!-- le righe seguenti servono a visualizzare i link per consentire di vedere tutti i commenti inseriti nelle carie aree -->
  31.     <a href="pagine/commenti.php" class="tema">Tutti i commenti</a>
  32.     <span class="normale">Cliccando sul titolo i commenti vengono visualizzati per data descrescente. Se invece vuoi vedere i commenti visualizzati dal pi∙ letto al meno letto, clicca su questo link: <a href="pagine/commenti.php?ord=plus" class="arg">commenti pi∙ letti</a></span>
  33. </div>
  34. <?php
  35.     // estraggo le aree
  36.     $sql_1="SELECT id_area,testo_area FROM area ORDER BY testo_area";
  37.     $ris_1=mysql_query($sql_1);
  38.     while ($tab_1=mysql_fetch_array($ris_1)) {
  39.         // per ogni area estratta inserisco il link dell'area stessa e scrivo una query per ricavare gli argomenti relativi all'area
  40.         echo "<div class='tem'><a href='pagine/commenti.php?area=".$tab_1[id_area]."' class='tema'>".$tab_1[testo_area]."</a>";
  41.         $sql_2="SELECT argomento.testo_argomento AS testo, argomento.id_argomento AS id FROM argomento,area WHERE argomento.id_area=area.id_area AND area.id_area='".$tab_1[id_area]."' ORDER BY argomento.testo_argomento";
  42.         $ris_2=mysql_query($sql_2);
  43.         echo "<span class='normale'>Argomenti: </span>";
  44.         while ($tab_2=mysql_fetch_array($ris_2)) {
  45.             // scrivo i link a tutti gli argomenti di quell'area
  46.             echo "<a href='pagine/commenti.php?arg=".$tab_2[id]."' class='arg'>".$tab_2[testo]."</a> | ";
  47.         }
  48.         // le query 3 e 4 servono a ricavare, per ogni area, il commento pi∙ letto e l∞ultimo scritto
  49.         $sql_3="SELECT commento.titolo, argomento.testo_argomento,commento.id_commento FROM commento,argomento WHERE commento.pubblicabile='si' AND commento.id_argomento=argomento.id_argomento AND argomento.id_area='".$tab_1[id_area]."' ORDER BY commento.data_ins DESC LIMIT 0,1";
  50.         $ris_3=mysql_query($sql_3);
  51.         $tab_3=mysql_fetch_array($ris_3);    
  52.         echo "<p><span class='normale'>Ultimo articolo inserito: </span><a href='pagine/commenti.php?comm=".$tab_3[2]."' class='art'>".$tab_3[0]."</a> <span class='normale'>[".$tab_3[1]."]</span>";
  53.         $sql_4="SELECT commento.titolo, argomento.testo_argomento,commento.id_commento FROM commento,argomento WHERE commento.pubblicabile='si' AND commento.id_argomento=argomento.id_argomento AND argomento.id_area='".$tab_1[id_area]."' ORDER BY click DESC LIMIT 0,1";
  54.         $ris_4=mysql_query($sql_4);
  55.         $tab_4=mysql_fetch_array($ris_4);
  56.         echo "<br /><span class='normale'>Articolo pi∙ letto: </span><a href='pagine/commenti.php?comm=".$tab_4[2]."' class='art'>".$tab_4[0]."</a> <span class='normale'>[".$tab_4[1]."]</span></div>";    
  57.     }
  58. ?>
  59. <div class="paragrafo">Contattaci</div>
  60. <span class="normale">
  61. <?php
  62.     // visualizzo il testo che nella tabella testi_admin corrisponde all'identificativo 'home_m'
  63.     echo $home['home_m'];
  64.     mysql_close();
  65. ?>
  66. <p>
  67. <a href="pagine/formmail.php">Scrivici</a><br />
  68. <a href="pagine/formmailing.php">Mailing list</a>
  69. </span>
  70. </body>
  71. </html>